package com.atguigu.rabbitmq.six;


import com.atguigu.rabbitmq.util.RabbitMqUtils;
import com.rabbitmq.client.Channel;

import java.util.Scanner;

/**
 *  发消息 交换机
 */
public class EmitLog {

    // 交换机的名称
    public static final String EXCHANGE_NAME = "direct_logs";

    public static void main(String[] args) throws Exception {

        // 获取信到
        Channel channel = RabbitMqUtils.getChannel();

        // 声明交换机  已经有了
        // channel.exchangeDeclare(EXCHANGE_NAME,"fauout");

        Scanner scanner = new Scanner(System.in);

        while ( scanner.hasNext() ) {
            String message = scanner.next();
            // 发送消息, 发送到指定routingkey ,第二个参数
            channel.basicPublish(EXCHANGE_NAME ,"error" ,null ,  message.getBytes("UTF-8") );
            System.out.println("生产者发出消息，消息："+message);

        }
    }
}
